let url = 'https://test.jiafan-tech.cn/tenant/common/image/post'
let Authorization =
	`Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImVjYWZmMjllLWU4ODUtMTFlZS04NTk3LTUyNTQwMDhkNjY2ZiIsIm5hbWUiOiJcdTVmOTBcdTZkMGIiLCJ0ZWxlcGhvbmUiOiIxNTkyMzM4Mzk1MyJ9.FWz-co9tK4cECF73yNr3udHLRAgTDbGSje0EyYHQYaY` // 这里设置 token

export default (filePath) => {
	return new Promise(async (resolve, rejects) => {
		try {
			uni.uploadFile({
				url,
				filePath,
				name: "file",
				header: {
					"Content-Type": "multipart/form-data",
					Authorization
				},
				success: (uploadFileRes) => {
					uni.hideLoading()
					console.log(uploadFileRes, 'uploadFileRes');
					if (uploadFileRes.statusCode !== 200) {
						// 视频上传失败了
						return rejects(uploadFileRes.errMsg);
					}
					const {
						imgPath,
						img
					} = JSON.parse(uploadFileRes.data).data;
					const codeImg = imgPath + img;
					return resolve(codeImg)
				},
			});
		} catch (e) {
			return rejects(e, 'ee上传失败')
		}
	})
}